﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace QuickFramework.SqlSugarOrm
{
    public interface IUnitOfWork : IDisposable, Shared.Contracts.IDependency
    {
        /// <summary>
        /// 创建数据库链接
        /// </summary>
        /// <param name="isMaster"></param>
        /// <returns></returns>
        IUnitOfWork CreateUoW(string connectionStringName = "Default", bool isMaster = true);

        public SqlSugarClient SqlSugarClient
        {
            get;
        }
        /// <summary>
        /// UnitOfWork ID
        /// </summary>
        public string ID
        {
            get;
        }
        /// <summary>
        /// 开启事务
        /// </summary>
        IUnitOfWork BeginTransaction();
        /// <summary>
        /// 提交事务
        /// </summary>
        void Commit();
        /// <summary>
        /// 回滚事务
        /// </summary>
        void Rollback();
        /// <summary>
        /// 销毁 / 关闭链接对象
        /// </summary>
        new void Dispose();
    }
}
